#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;
class Solution{
public:
	void reverseString(string &s) {
		int i = 0;
		int len = s.size();
		while(i<len){
			int j = 0;
			while(i+j<len && s[i+j] != ' '){
				j++;
			}
			int begin = i;
			int end = i+j-1;
			while(begin < end){
				auto tmp = s[begin];
				s[begin] = s[end];
				s[end] = tmp;
				begin++;
				end--;
			}
			i = i+j+1;
		}
    }
};

int main(){
	string s = "Let's take LeetCode contest";
	Solution so;
	so.reverseString(s);
	cout << s << endl;
	return 0;
}